public class Student extends Person {
    private String[] courses;

    public Student(String name, int id) {
        super(name, id);  // 调用父类构造方法
        this.courses = new String[5];
    }

    public void selectCourse(String course) {
        for (int i = 0; i < courses.length; i++) {
            if (courses[i] == null) {
                courses[i] = course;
                System.out.println(name + " 选课成功：" + course);
                return;
            }
        }
        System.out.println("选课数量已达上限");
    }

    @Override
    public void printSchedule() {
        System.out.println("学生 " + name + " 的课表：");
        for (String course : courses) {
            if (course != null) {
                System.out.println("- " + course);
            }
        }
    }
}